package com.java.annotation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author liyanhao
 * @Date 2023-02-23 19:58
 */
public class Test {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        HelloAnnotationClient helloAnnotationClient = new HelloAnnotationClient();
        Method sayHello = helloAnnotationClient.getClass().getMethod("sayHello");
        if (sayHello.isAnnotationPresent(HelloAnnotation.class)) {
            HelloAnnotation annotation = sayHello.getAnnotation(HelloAnnotation.class);
            System.out.println("value:" + annotation.value());
            sayHello.invoke(helloAnnotationClient);
        }
    }
}
